/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * Die Capacity Entität bildet die Menge an Stundenkapazität ab mit der ein
 * Mitglied eines Scrumteams einem Sprint zugeteilt ist.
 * @author Alexander Cannell
 */
@Entity
@Table(name = "CAPACITY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Capacity.findAll", query = "SELECT c FROM Capacity c"),
    @NamedQuery(name = "Capacity.findByCapid", query = "SELECT c FROM Capacity c WHERE c.capid = :capid"),
    @NamedQuery(name = "Capacity.findByCap", query = "SELECT c FROM Capacity c WHERE c.cap = :cap"),
    @NamedQuery(name = "Capacity.findBySprint", query = "SELECT c FROM Capacity c WHERE c.sprint = :sprint"),
    @NamedQuery(name = "Capacity.findByUser", query = "SELECT c FROM Capacity c WHERE c.user = :user")})
public class Capacity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "CAPID")
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer capid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CAP")
    private int cap;

    @ManyToOne
    @JoinColumn(name="ACC",referencedColumnName="LOGINID")
    Userloginaccount user;
    
    @ManyToOne
    @JoinColumn(name="SPRINT",referencedColumnName="SPRINTID")
    Sprint sprint;

    public Sprint getSprint() {
        return sprint;
    }

    public void setSprint(Sprint sprint) {
        this.sprint = sprint;
    }

    public Userloginaccount getUser() {
        return user;
    }

    public void setUser(Userloginaccount user) {
        this.user = user;
    }

    public Capacity() {
    }

    public Capacity(Integer capid) {
        this.capid = capid;
    }

    public Capacity(Integer capid, int cap) {
        this.capid = capid;
        this.cap = cap;
    }

    public Integer getCapid() {
        return capid;
    }

    public void setCapid(Integer capid) {
        this.capid = capid;
    }

    public int getCap() {
        return cap;
    }

    public void setCap(int cap) {
        this.cap = cap;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (capid != null ? capid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Capacity)) {
            return false;
        }
        Capacity other = (Capacity) object;
        if ((this.capid == null && other.capid != null) || (this.capid != null && !this.capid.equals(other.capid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "smary.ejb.entity.Capacity[ capid=" + capid + " ]";
    }
    
}
